package shiro;

import cn.cqone.crm.domain.Permission;
import cn.cqone.crm.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class ShiroFilterMapFactory {
     @Autowired
     private PermissionService permissionService;
     public Map<String,String> createMap(){
        Map<String,String> map = new LinkedHashMap<>();
        //anon:需要放行的路径
        map.put("/system/login","anon");
        map.put("/swagger-ui.html","anon");
        map.put("*.js","anon");
        map.put("*.css","anon");
        map.put("/css/**","anon");
        map.put("/js/**","anon");
        map.put("/images/**","anon");
        map.put("//configuration/ui","anon");
        map.put("/webjars/**","anon");
        map.put("/js/**","anon");
          List<Permission> permissions = permissionService.findAll();
        map.put("/swagger-ui.html/","anon");
/*        map.put("/webjars/**","anon");
        map.put("/menu/findMenuByEmployeeId","anon");*/
/*        List<Permission> permissions = permissionService.findAll();






          permissions.forEach(permission->{
                map.put(permission.getUrl(),"myFilter["+permission.getSn()+"]");
          });
          });*/
          //authc:拦截
        map.put("/**","myFilter");
         map.put("/**","myFilter");
        return map;
    }
}